/**
 * Created by 白雨浓 on 2017/12/23 15:04.
 */
export default {
  update(self){
    let output = `UPDATE \`${self.tableName}\`
SET`;

    for (const param of self.params) {
      if (param.type === 'int' || param.type === 'boolean') continue;
      if (param.name.toLowerCase().indexOf('id') >= 0) continue;
      if (param.name.toLowerCase().indexOf('time') >= 0) {
        if (param.name.toLowerCase().indexOf('update') >= 0) {
          output += '\n`update_time` = NOW()';
          continue;
        }
        continue;
      }
      output += `\n<if test="${param.name} != null">${self.toUnderline(param.name)} = #{${param.name}},</if>`
    }
    output += '\nWHERE';
    for (const param of self.params) {
      if (param.name !== 'id' && param.name.toLowerCase().indexOf('id') >= 0) {
        output += `\n(\`${self.toUnderline(param.name)}\` = #{${param.name}});`;
        break;
      }
    }
    self.output = output;
  }
}
